/*
 Copyright (C) 2009 QDSS.org
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.qdss.persist.engine.query;

/**
 * 
 * 
 * @author <a href="mailto:zhaofang123@gmail.com">FANGFANG ZHAO</a>
 * @see 0.1.0, May 25, 2009
 * @version $Id: BaseQuery.java 67 2010-03-11 07:16:29Z zhaofang123@gmail.com $
 */
public abstract class BaseQuery<T> implements IQuery<T> {

	private int firstResult;
	private int maxResults;
	private int timeout;

	protected int limit, offset;

	public int getFirstResult() {
		return firstResult;
	}

	@SuppressWarnings("unchecked")
	public T setFirstResult(int firstResult) {
		this.firstResult = firstResult;
		return (T) this;
	}

	public int getMaxResults() {
		return maxResults;
	}

	@SuppressWarnings("unchecked")
	public T setMaxResults(int maxResults) {
		this.maxResults = maxResults;
		return (T) this;
	}

	public int getTimeout() {
		return timeout;
	}

	@SuppressWarnings("unchecked")
	public T setTimeout(int timeout) {
		this.timeout = timeout;
		return (T) this;
	}
	
	public T setLimit(int limit) {
		return setLimit(limit, 0);
	}

	@SuppressWarnings("unchecked")
	public T setLimit(int limit, int offset) {
		this.limit = limit;
		this.offset = offset;
		return (T) this;
	}

	public boolean isLazyLoad() {
		throw new UnsupportedOperationException();
	}

	public T setParameter(int position, Object value) {
		throw new UnsupportedOperationException();
	}
}
